package com.wanxi.servlet.news;//package com.wanxi.servlet.news;
//
//import com.alibaba.fastjson2.JSONObject;
//import com.wanxi.model.NewsModel;
//import com.wanxi.model.ResultModel;
//import com.wanxi.service.NewsService;
//import com.wanxi.service.impl.NewsServiceImpl;
//import com.wanxi.util.Tool;
//
//import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
//import javax.servlet.http.HttpServlet;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@WebServlet("/back/news/add")
//public class NewAddServlet extends HttpServlet {
//    @Override
//    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        //1.乱码处理
//
//        //2.得到前端的值
//        String name = req.getParameter("name");
//        String source = req.getParameter("source");
//        String author = req.getParameter("author");
//        String number = req.getParameter("number");
//        String subject = req.getParameter("subject");
//        String isShow = req.getParameter("isShow");
//        String content = req.getParameter("content");
//        String whereShow = req.getParameter("whereShow");
//        String enable = req.getParameter("enable");
//        String isRecommend = req.getParameter("isRecommend");
//        String createTime = req.getParameter("createTime");
//        String newsclassificationId = req.getParameter("newsclassificationId");
//        //3.封装到model
//        NewsModel newsModel=new NewsModel();
//        newsModel.setName(Tool.nullToStr(name));
//        newsModel.setSource(Tool.nullToStr(source));
//        newsModel.setAuthor(Tool.nullToStr(author));
//        newsModel.setNumber(Tool.strToInt(number));
//        newsModel.setSubject(Tool.nullToStr(subject));
//        newsModel.setIsShow(Tool.strToInt(isShow));
//        newsModel.setNewsclassificationId(Tool.strToInt(newsclassificationId));
//        newsModel.setIsRecommend(Tool.strToInt(isRecommend));
//        newsModel.setEnable(Tool.strToInt(enable));
//        newsModel.setWhereShow(Tool.strToInt(whereShow));
//        newsModel.setContent(Tool.nullToStr(content));
//        newsModel.setCreateTime(Tool.nullToDate(createTime));
//        //  4.调用service
//        NewsService newsService=new NewsServiceImpl();
//        //5.调用service的方法并得到返回值
//        ResultModel resultModel=newsService.add(newsModel);
//        //6.返回前端
//        resp.getWriter().println(JSONObject.toJSONString(resultModel));
//    }
//}
